package com.resou.reader.utils;

import com.resou.reader.api.entry.LoginData;
import com.resou.reader.mine.IView.UserInstance;

public class UserUtil {
    /**
     * 获取用户token
     *
     * @return
     */
    public static String getToken() {
        String token = UserInstance.getToken();
        if (token == null) {
            return "";
        }
        return token;
    }

    /**
     * 检测是否已登录
     *
     * @return
     */
    public static boolean checkIsLoggedIn() {
        return UserInstance.isLogin();
    }

    /**
     * 检测登录状态
     *
     * @return
     */
    public boolean checkLoginStatus() {
        String token = UserUtil.getToken();
        if (token == null) {
            ToastUtil.makeShortToast("您尚未登录，请登录后重试");
            return false;
        }
        return true;
    }

    public static String getNickName() {
        LoginData loginData = UserInstance.getLoginData();
        if (loginData == null) {
            return "";
        }
        String nickName = loginData.getNickName();
        if (nickName == null) {
            return "";
        }
        return nickName;
    }

    public static String getHeadPic() {
        return UserInstance.getLoginData().getHead_pic();
    }
}
